package com.shrcl.engineerprocess.domain.impl;

import com.shrcl.engineerprocess.domain.CorpWeChatUser;
import com.shrcl.engineerprocess.domain.CorpWeChatUserCriteria;
import com.shrcl.engineerprocess.domain.Engineer;
import edu.fudan.mylang.pf.query.HQLBasedPagedQueryCriteria;
import org.hibernate.Query;

public class CorpWeChatUserCriteriaImpl extends HQLBasedPagedQueryCriteria<CorpWeChatUser> implements CorpWeChatUserCriteria {
  private Engineer engineer;
  
  public Engineer getEngineer() {
    return this.engineer;
  }
  
  public CorpWeChatUserCriteria setEngineer(final Engineer engineer) {
    this.engineer = engineer;
    return this;			
    
  }
  
  private String info;
  
  public String getInfo() {
    return this.info;
  }
  
  public CorpWeChatUserCriteria setInfo(final String info) {
    this.info = info;
    return this;			
    
  }
  
  private Boolean excluded;
  
  public Boolean getExcluded() {
    return this.excluded;
  }
  
  public CorpWeChatUserCriteria setExcluded(final Boolean excluded) {
    this.excluded = excluded;
    return this;			
    
  }
  
  protected String buildHQLFrom() {
    return " from com.shrcl.engineerprocess.domain.impl.CorpWeChatUserImpl this ";
  }
  
  protected String buildHQLBody() {
    String hql = "where 1 = 1 ";
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getInfo()) && !edu.fudan.mylang.pf.query.QueryUtil.isNull(getInfo()) ){
    	hql += " and ((this.engineer.name  LIKE :info) or (this.wechatid  LIKE :info))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getExcluded()) ){
    	hql += " and ((this.excluded) = (:excluded))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getEngineer()) ){
    	hql += " and ((this.engineer) = (:engineer))" ;
    }
    return hql;
    
  }
  
  public void initOrderBys() {
    
  }
  
  protected void fillParameter(final Query query) {
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getEngineer())){
    	query.setParameter("engineer",getEngineer()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getInfo())){
    	query.setParameter("info",getInfo()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getExcluded())){
    	query.setParameter("excluded",getExcluded()) ;
    }			
    
  }
  
  protected Boolean isDistinct() {
    return false;
  }
  
  public CorpWeChatUserCriteriaImpl() {
    initOrderBys();
  }
}
